package com.ztn.sdk.iot.api;

import com.fasterxml.jackson.core.type.TypeReference;
import com.ztn.sdk.iot.api.util.HttpTool;
import com.ztn.sdk.iot.api.req.DeviceSensorListWithReq;
import com.ztn.sdk.iot.api.res.BaseRes;
import com.ztn.sdk.iot.api.res.DeviceSensorWith;
import com.ztn.sdk.iot.api.util.JsonTool;

import java.util.ArrayList;
import java.util.List;

public class IotDeviceSensorTool {

    private static final String BASE_PATH = "iot/api/v1/v1/device/sensor/";

    public static List<DeviceSensorWith> list(DeviceSensorListWithReq req) {
        String path = BASE_PATH + "list";
        BaseRes<List<DeviceSensorWith>> res = HttpTool.doPost(path, JsonTool.toJson(req), new TypeReference<BaseRes<List<DeviceSensorWith>>>() {
        });
        if (null != res && null != res.data) {
            return res.data;
        }
        return new ArrayList<>();
    }
}
